package com.syq.dao.impl;

import com.syq.bean.Grade;
import com.syq.dao.GradeDao;
import com.syq.util.DBUtils;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class GradeDaoImpl extends DBUtils implements GradeDao {
    @Override
    public List<Grade> getList() {
        String sql = "select * from grade";
        List<Grade> grades = new ArrayList<>();
        try {
            resultSet = query(sql,null);
            while (resultSet.next()) {
                Grade grade = new Grade();
                grade.setGradeId(resultSet.getInt("gradeid"));
                grade.setGradeName(resultSet.getString("gradename"));
                grades.add(grade);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            closeAll();
        }
        return grades;
    }
}
